package com.wlyuan.open.remote.feign.fallover;

import com.wlyuan.open.dto.top.OpenTopExtensionOrderSyncDTO;
import com.wlyuan.open.infrastructure.exception.OpenPlatformError;
import com.wlyuan.open.remote.feign.TopWebFeignInvoker;
import com.wlyuan.tools.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author lijing
 * @description
 */
@Component
@Slf4j
public class TopWebFeignFallOverFactory implements FallbackFactory<TopWebFeignInvoker> {
    @Override
    public TopWebFeignInvoker create(Throwable cause) {
        return new TopWebFeignInvoker() {
            @Override
            public Result<Long> rewrite(OpenTopExtensionOrderSyncDTO creation) {
                return new Result(OpenPlatformError.SOURCE_VALUE_ERROR.getCode(), OpenPlatformError.SOURCE_VALUE_ERROR.getMessage());
            }
        };
    }
}
